/**
 * Created by tanbingqin on 2019/1/24.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'

export default {
  //获取可关闭申请单列表
  getRequestList(page, size, searchParams){
    let url = `${config.baseUrl}/api/application/budget/close/list?page=${page}&size=${size}`;
    for(let searchName in searchParams) {
      if (searchName === 'formOIDs') {
        if (searchParams[searchName] !== 'all') {
          url += `&formOIDs=${searchParams[searchName]}`;
        }
      } else if (searchName === 'businessCodeKey' && searchParams[searchName]) {
        url += `&businessCodeKey=${encodeURIComponent(searchParams[searchName])}`;
      } else if (searchName !== 'selectedRowKeys' && searchName !== 'selectedRows' && searchName !== 'businessCodeKeyLable') {
        url += searchParams[searchName] ? `&${searchName}=${searchParams[searchName]}` : ''
      }
    }
    return httpFetch.get(url);
  },

  //获取关闭列表的表单
  getDocumentType(params) {
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/search/param`, params)
  },

  //批量关闭整单
  handleClose(params) {
    return httpFetch.post(`${config.baseUrl}/api/application/batch/budget/close`, params)
  },
}
